package com.ticket.system.service.impl;

import java.util.List;
import com.ticket.common.utils.DateUtils;
import com.ticket.system.domain.vo.HallAreaVo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ticket.system.mapper.YanchuHallAreaMapper;
import com.ticket.system.domain.YanchuHallArea;
import com.ticket.system.service.IYanchuHallAreaService;

/**
 * 场馆区域Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@Service
public class YanchuHallAreaServiceImpl implements IYanchuHallAreaService 
{
    @Autowired
    private YanchuHallAreaMapper yanchuHallAreaMapper;

    /**
     * 查询场馆区域
     * 
     * @param id 场馆区域主键
     * @return 场馆区域
     */
    @Override
    public YanchuHallArea selectYanchuHallAreaById(Long id)
    {
        return yanchuHallAreaMapper.selectYanchuHallAreaById(id);
    }

    /**
     * 查询场馆区域列表
     * 
     * @param yanchuHallArea 场馆区域
     * @return 场馆区域
     */
    @Override
    public List<YanchuHallArea> selectYanchuHallAreaList(YanchuHallArea yanchuHallArea)
    {
        return yanchuHallAreaMapper.selectYanchuHallAreaList(yanchuHallArea);
    }
    @Override
    public List<HallAreaVo> selectHallAreaVoList(YanchuHallArea yanchuHallArea){
        List<HallAreaVo> vos = Lists.newArrayList();
        List<YanchuHallArea> areas = selectYanchuHallAreaList(yanchuHallArea);
        if(CollectionUtils.isEmpty(areas)){
            return vos;
        }
        HallAreaVo vo = null;
        for(YanchuHallArea area:areas){
            vo = new HallAreaVo();
            vo.setId(area.getId());
            vo.setAreaName(area.getAreaName());
            vo.setHallId(area.getHallId());
            vo.setSeatState(area.getSeatState());
            vo.setSeatNumsRow(area.getSeatNumsRow());
            vo.setRowType(area.getRowType());
            vo.setRowNums(area.getRowNums());
            vos.add(vo);
        }
        return vos;
    }

    /**
     * 新增场馆区域
     * 
     * @param yanchuHallArea 场馆区域
     * @return 结果
     */
    @Override
    public int insertYanchuHallArea(YanchuHallArea yanchuHallArea)
    {
        yanchuHallArea.setCreateTime(DateUtils.getNowDate());
        return yanchuHallAreaMapper.insertYanchuHallArea(yanchuHallArea);
    }

    /**
     * 修改场馆区域
     * 
     * @param yanchuHallArea 场馆区域
     * @return 结果
     */
    @Override
    public int updateYanchuHallArea(YanchuHallArea yanchuHallArea)
    {
        yanchuHallArea.setUpdateTime(DateUtils.getNowDate());
        return yanchuHallAreaMapper.updateYanchuHallArea(yanchuHallArea);
    }

    /**
     * 批量删除场馆区域
     * 
     * @param ids 需要删除的场馆区域主键
     * @return 结果
     */
    @Override
    public int deleteYanchuHallAreaByIds(Long[] ids)
    {
        return yanchuHallAreaMapper.deleteYanchuHallAreaByIds(ids);
    }

    /**
     * 删除场馆区域信息
     * 
     * @param id 场馆区域主键
     * @return 结果
     */
    @Override
    public int deleteYanchuHallAreaById(Long id)
    {
        return yanchuHallAreaMapper.deleteYanchuHallAreaById(id);
    }
}
